﻿<UserControl x:Class="TourreauGilles.CciExplorer.Windows.Explorer.ExplorerView" x:ClassModifier="internal"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:explorer="clr-namespace:TourreauGilles.CciExplorer.Windows.Explorer"
             mc:Ignorable="d">
    <TreeView ItemsSource="{Binding Assemblies}">
        <TreeView.ItemContainerStyle>
            <Style TargetType="{x:Type TreeViewItem}">
                <Setter Property="IsExpanded" Value="{Binding IsExpanded, Mode=TwoWay}" />
                <Setter Property="IsSelected" Value="{Binding IsSelected, Mode=TwoWay}" />
            </Style>
        </TreeView.ItemContainerStyle>

        <TreeView.Resources>
            <HierarchicalDataTemplate DataType="{x:Type explorer:NodeViewModel}" ItemsSource="{Binding Nodes}">
                <TextBlock Text="{Binding Name}" />
            </HierarchicalDataTemplate>

            <HierarchicalDataTemplate DataType="{x:Type explorer:AssemblyNodeViewModel}" ItemsSource="{Binding Nodes}">
                <StackPanel Orientation="Horizontal">
                    <Image Style="{StaticResource AssemblyImage}" Margin="3,0" />
                    <TextBlock Text="{Binding Name}" />
                </StackPanel>
            </HierarchicalDataTemplate>

            <HierarchicalDataTemplate DataType="{x:Type explorer:NamespaceNodeViewModel}" ItemsSource="{Binding Nodes}">
                <StackPanel Orientation="Horizontal">
                    <Image Style="{StaticResource NamespacePublicImage}" Margin="3,0" />
                    <TextBlock Text="{Binding Name}" />
                </StackPanel>
            </HierarchicalDataTemplate>

            <HierarchicalDataTemplate DataType="{x:Type explorer:TypeNodeViewModel}" ItemsSource="{Binding Nodes}">
                <StackPanel Orientation="Horizontal">
                    <Image Style="{StaticResource ClassPublicImage}" Margin="3,0" />
                    <TextBlock Text="{Binding Name}" />
                </StackPanel>
            </HierarchicalDataTemplate>

            <HierarchicalDataTemplate DataType="{x:Type explorer:MethodNodeViewModel}" ItemsSource="{Binding Nodes}">
                <StackPanel Orientation="Horizontal">
                    <Image Name="MethodImage" Margin="3,0" />
                    <TextBlock Text="{Binding Name}" />
                </StackPanel>
                <HierarchicalDataTemplate.Triggers>
                    <DataTrigger Binding="{Binding Visibility}" Value="Public">
                        <Setter TargetName="MethodImage" Property="Style" Value="{StaticResource MethodPublicImage}" />
                    </DataTrigger>
                    <DataTrigger Binding="{Binding Visibility}" Value="Assembly">
                        <Setter TargetName="MethodImage" Property="Style" Value="{StaticResource MethodInternalImage}" />
                    </DataTrigger>
                    <DataTrigger Binding="{Binding Visibility}" Value="Family">
                        <Setter TargetName="MethodImage" Property="Style" Value="{StaticResource MethodProtectedImage}" />
                    </DataTrigger>
                    <DataTrigger Binding="{Binding Visibility}" Value="Private">
                        <Setter TargetName="MethodImage" Property="Style" Value="{StaticResource MethodPrivateImage}" />
                    </DataTrigger>
                </HierarchicalDataTemplate.Triggers>
            </HierarchicalDataTemplate>

            <HierarchicalDataTemplate DataType="{x:Type explorer:PropertyNodeViewModel}" ItemsSource="{Binding Nodes}">
                <StackPanel Orientation="Horizontal">
                    <Image Name="PropertyImage" Margin="3,0" />
                    <TextBlock Text="{Binding Name}" />
                </StackPanel>
                <HierarchicalDataTemplate.Triggers>
                    <DataTrigger Binding="{Binding Visibility}" Value="Public">
                        <Setter TargetName="PropertyImage" Property="Style" Value="{StaticResource PropertyPublicImage}" />
                    </DataTrigger>
                    <DataTrigger Binding="{Binding Visibility}" Value="Assembly">
                        <Setter TargetName="PropertyImage" Property="Style" Value="{StaticResource PropertyInternalImage}" />
                    </DataTrigger>
                    <DataTrigger Binding="{Binding Visibility}" Value="Family">
                        <Setter TargetName="PropertyImage" Property="Style" Value="{StaticResource PropertyProtectedImage}" />
                    </DataTrigger>
                    <DataTrigger Binding="{Binding Visibility}" Value="Private">
                        <Setter TargetName="PropertyImage" Property="Style" Value="{StaticResource PropertyPrivateImage}" />
                    </DataTrigger>
                </HierarchicalDataTemplate.Triggers>
            </HierarchicalDataTemplate>

            <HierarchicalDataTemplate DataType="{x:Type explorer:EventNodeViewModel}" ItemsSource="{Binding Nodes}">
                <StackPanel Orientation="Horizontal">
                    <Image Name="EventImage" Margin="3,0" />
                    <TextBlock Text="{Binding Name}" />
                </StackPanel>
                <HierarchicalDataTemplate.Triggers>
                    <DataTrigger Binding="{Binding Visibility}" Value="Public">
                        <Setter TargetName="EventImage" Property="Style" Value="{StaticResource EventPublicImage}" />
                    </DataTrigger>
                    <DataTrigger Binding="{Binding Visibility}" Value="Assembly">
                        <Setter TargetName="EventImage" Property="Style" Value="{StaticResource EventInternalImage}" />
                    </DataTrigger>
                    <DataTrigger Binding="{Binding Visibility}" Value="Family">
                        <Setter TargetName="EventImage" Property="Style" Value="{StaticResource EventProtectedImage}" />
                    </DataTrigger>
                    <DataTrigger Binding="{Binding Visibility}" Value="Private">
                        <Setter TargetName="EventImage" Property="Style" Value="{StaticResource EventPrivateImage}" />
                    </DataTrigger>
                </HierarchicalDataTemplate.Triggers>
            </HierarchicalDataTemplate>

            <HierarchicalDataTemplate DataType="{x:Type explorer:FieldNodeViewModel}" ItemsSource="{Binding Nodes}">
                <StackPanel Orientation="Horizontal">
                    <Image Name="FieldImage" Margin="3,0" />
                    <TextBlock Text="{Binding Name}" />
                </StackPanel>
                <HierarchicalDataTemplate.Triggers>
                    <DataTrigger Binding="{Binding Visibility}" Value="Public">
                        <Setter TargetName="FieldImage" Property="Style" Value="{StaticResource FieldPublicImage}" />
                    </DataTrigger>
                    <DataTrigger Binding="{Binding Visibility}" Value="Assembly">
                        <Setter TargetName="FieldImage" Property="Style" Value="{StaticResource FieldInternalImage}" />
                    </DataTrigger>
                    <DataTrigger Binding="{Binding Visibility}" Value="Family">
                        <Setter TargetName="FieldImage" Property="Style" Value="{StaticResource FieldProtectedImage}" />
                    </DataTrigger>
                    <DataTrigger Binding="{Binding Visibility}" Value="Private">
                        <Setter TargetName="FieldImage" Property="Style" Value="{StaticResource FieldPrivateImage}" />
                    </DataTrigger>
                </HierarchicalDataTemplate.Triggers>
            </HierarchicalDataTemplate>
        </TreeView.Resources>
    </TreeView>
</UserControl>
